package com.zhongfu.ai.common.config;

import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AiConfig {


    @Value("${spring.ai.ollama.base-url}")
    private String ollamaBaseUrl;

    @Value("${spring.ai.openai.base-url}")
    private String openaiBaseUrl;

    @Value("${spring.ai.openai.api-key}")
    private String openAiApiKey;

    @Bean
    public OllamaApi ollamaApi(){
        return OllamaApi
                .builder()
                .baseUrl(ollamaBaseUrl)
                .build();
    }

    @Bean
    public OpenAiApi openAiApi(){
        return OpenAiApi
                .builder()
                .baseUrl(openaiBaseUrl)
                .apiKey(openAiApiKey)
                .build();
    }
}
